<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #model {
            width: 100px;
            height: 100px;
            background-color: red;
        }
    </style>
</head>

<body>
    <button id="open">显示</button>
    <button id="down">隐藏</button>
    <script>
        const Model = (function () {
            let model = null
            return function () {
                if (!model) {
                    model = document.createElement("div")
                    model.id = "model"
                    model.style.display = "none"
                    model.innerText = "1"
                    document.body.appendChild(model)

                }
                return model


            }


        })()
        let open1 = document.getElementById("open")
        let down = document.getElementById("down")
        open1.addEventListener("click", function () {
            let model = new Model()
            model.style.display = "block"

        })
        down.addEventListener("click", function () {
            let model = new Model()
            model.style.display = "none"
        })

    </script>
</body>

</html>